// N.游戏.cpp
#include <algorithm>
#include <cstdio>
#include <cstring>
#include <functional>
#include <iostream>
#include <ostream>
#include <sstream>
#include <string>

#define lld long long // long long 的printf 占位符是lld
#define ENDL '\n'     // 将 endl 替换为 \n 取消缓冲区

const long long MAX_ = 1e9;

using std::cin;
using std::cout;
using std::endl;
using std::string;
const int N = 1e5 + 9;
lld a[N], k, s[N];
lld n;
void solve() {
  //
  cin >> n >> k;
  for (size_t i = 1; i <= n; ++i)
    cin >> a[i];
  std::sort(a + 1, a + 1 + n);
  if (n <= k) {
    cout << "-1";
    return;
  }

  for (size_t i = 1; i <= n; ++i)
    s[i] = s[i - 1] + a[i];

  int left = 0, right = n - k - 1;
  int result = -1;
  while (left <= right) {
    int i = (left + right) / 2;
    if (n - i <= k) {
      right = i - 1;
      continue;
    }
    lld s_hua = s[i + k] - s[i];
    lld s_ming = s[n] - s[i + k];
    if (s_ming > s_hua) {
      result = i;
      right = i - 1;
    } else
      left = i + 1;
  }
  // cout << result;
  printf("%d", result);
}
int main() {
  int T = 1;
  // cin >> T;
  while (T--) {
    solve();
  }
}